/*
 * Panel.fx
 *
 * Created on 17/12/2008, 14:24:05
 */

package socialcampx;

import javafx.scene.CustomNode;
import javafx.scene.effect.Effect;
import javafx.scene.effect.Shadow;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.scene.image.ImageView;
import javafx.scene.image.Image;
import javafx.scene.shape.Polygon;

public class Panel extends CustomNode {

    public var x: Number = 0;
    public var y: Number = 0;
    public var width: Number = 0;
    public var height: Number = 0;
    public var color: Color = Color.BLACK;
    public var text: String;
    public var image_url: String;
    public var info: String;

    public override function create(): Node {
        return Group {
            content: [
                Group {
                    content: [
                        /*Rectangle {
                        x: x+10
                         y: y+10
                         width: width
                         height: height
                         fill: Color.BLACK
                         stroke: color
                         opacity: 0.5
                         effect: Constants.shadow
                         },*/
                        Rectangle {
                            x: x
                            y: y
                            width: width
                            height: height
                            fill: Color.WHITE
                            //stroke: color
                            opacity: Constants.POST_ALPHA
                            arcWidth: 30
                            arcHeight: 30
                        },
                        Text {
                            font: Font {
                                size: 12
                            }
                            x: x + 10
                            y: y + 20
                            content: text
                            wrappingWidth: width - 20
                        },
                        Polygon {
                            points: [ x+30,y+height, x+60,y+height, x+45,y+height+Constants.GAP_POST_IMAGE ]
                            fill: Color.WHITE
                            //stroke: color
                            opacity: Constants.POST_ALPHA

                        },
                        ImageView {
                            image: Image {
                                url: image_url
                                width: 50
                                height: 50
                                backgroundLoading: true
                            }
                            x: x + 20
                            y: y + height + Constants.GAP_POST_IMAGE
                        },
                        Rectangle {
                            x: x + 20 + 50 + 5
                            y: y + height + Constants.GAP_POST_IMAGE
                            width: 160
                            height: 50
                            fill: Color.WHITE
                            stroke: color
                            opacity: Constants.POST_ALPHA
                        },
                        Text {
                            font: Font {
                                size: 13
                                embolden: true
                            }
                            x: x + 20 + 50 + 10
                            y: y + height + Constants.GAP_POST_IMAGE + 20
                            content: info
                            wrappingWidth: 160
                        },
                    ]
                }
            ]
        };
    }
}